<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>{$gallery.gallery_name}</title>
    <!-- Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
        var kk = {$config};
        wx.config(kk);
        wx.ready(function(){

        });
        wx.onMenuShareAppMessage({
    title: '李威高效学习法（厦门）见面会', // 分享标题
    desc: '李威高效学习法（厦门）见面会', // 分享描述
    link: 'http://www.aierfen.com/img/25.jpg', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
    imgUrl: 'http://www.aierfen.com/img/25.jpg', // 分享图标
    success: function () {
            // 用户确认分享后执行的回调函数
            // alert(1);
        },
        fail: function () {
            // 用户取消分享后执行的回调函数
            // alert(res);
        }
    });
    wx.onMenuShareTimeline({
        title: '李威高效学习法（厦门）见面会', // 分享标题
        link: '{$shareUrl}', // 分享链接
        imgUrl: 'http://www.aierfen.com/img/25.jpg', // 分享图标
        success: function () {
            // 用户确认分享后执行的回调函数
            // alert(1);
        },
        fail: function (res) {
            // 用户取消分享后执行的回调函数
            // alert(res);
        }
    });
    </script>
</head>
<body>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">提醒消息</h4>
            </div>
            <div class="modal-body" id="errContent">
                错误信息
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <!--<button type="button" class="btn btn-primary">Save changes</button>-->
            </div>
        </div>
    </div>
</div>
<img src="{$gallery.head_img}" class="img-responsive" alt="Responsive image">
<div class="panel panel-default">
    <div class="panel-body">
        <form method="post" enctype="multipart/form-data" id="form1">
            {volist name="question" id="vo"}
            {if condition="$vo.type eq 'count' "}
            <div class="form-group" style="text-align: center">
                <span>浏览人数:{$viewCounts}</span> <span>{$vo.tag}:{$atendCounts}</span>
            </div>
            {/if}
            {if condition="$vo.type eq 'title' "}
            <div class="jumbotron">
                <p style="text-align: center;font-weight: bold">{$vo.tag}</p>
            </div>
            {/if}
            {if condition="$vo.type eq 'text' "}
            <div class="form-group">
                <label for="exampleInputName2">{$vo.tag}</label>
                <textarea class="form-control" name="{$vo.name}" rows="{$vo.row|default=3}" readonly>{$vo.input_value|default=''}</textarea>
            </div>
            {/if}
            {if condition="$vo.type eq 'file' "}
            <div class="form-group">
                <label for="exampleInputFile">{$vo.tag}</label>
                <img src="" id="{$vo.name}_kk_preview" class="img-responsive">
                <input type="file" name="{$vo.name}_kk" onchange="preview(this)" multiple="multiple">
                <input type="text" name="{$vo.name}" id="{$vo.name}" value="" hidden>
            </div>
            {/if}
            {if condition="$vo.type eq 'checkbox' "}
            <div class="checkbox">
                <label>
                    <input type="checkbox" name="{$vo.name}" >{$vo.tag}
                </label>
            </div>
            {/if}
            {if condition="$vo.type eq 'radio' "}
            <div class="radio">
                {volist name="$vo.option_text" id="voo"}
                <label>
                    <input type="radio" name="{$vo.name}"  value="{$voo.value}" >{$voo.tag}
                </label>
                {/volist}
            </div>
            {/if}
            {if condition="$vo.type eq 'head' "}
            <div class="page-header" style="text-align: center">
                <h1><small>{$vo.tag}</small></h1>
            </div>
            {/if}
            {if condition="$vo.type eq 'input' "}
            <div class="form-group">
                <label for="exampleInputName2">{$vo.tag}</label>
                <input name="{$vo.name}" type="text" class="form-control" value="{$vo.input_value|default=''}"  placeholder="{$vo.placeholder|default=''}" readonly>
            </div>
            {/if}
            {if condition="$vo.type eq 'desc' "}
            <div class="alert alert-success" role="alert">
                {volist name="$vo.paragraph" id="po"}
                <p>{$po}</p>
                {/volist}
            </div>
            {/if}
            {if condition="$vo.type eq 'option' "}
            <div class="form-group">
                <label for="exampleInputName2">{$vo.tag}</label>
                <input name="{$vo.name}" type="text" class="form-control" value="{$vo.input_value|default=''}"  placeholder="{$vo.placeholder|default=''}" readonly>
            </div>
            {/if}
            <!--{if condition="$vo.type eq 'submit' "}-->
            <!--<div class="form-group" style="text-align: center">-->
                <!--<button type="button" class="btn btn-default" onclick="login()">{$vo.tag}</button>-->
            <!--</div>-->
            <!--{/if}-->
            {if condition="$vo.type eq 'image' "}
            <img src="{$vo.name}" class="img-responsive" alt="Responsive image">
            {/if}
            {if condition="$vo.type eq 'textline' "}
            <div class="form-group" style="text-align: center">
                <p style="text-align: center">{$vo.tag}</p>
            </div>
            {/if}
            {/volist}
        </form>
    </div>
</div>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
    function preview(file) {
        if (file.files && file.files[0]) {
            var reader = new FileReader();
            reader.onload = function (evt) {
                var kk = file.name + '_preview';
                var element = document.getElementById(kk);
                element.src = evt.target.result;
            }
            reader.readAsDataURL(file.files[0]);
            data = new FormData();
            data.append('pic_name',file.name);
            var oldName = file.name;
            var photoRealName = oldName.substring(0,oldName.length-3);
            data.append(file.name,file.files[0]);
            $.ajax({
                type: "POST",
                dataType: 'json',
                url: "/mobile/image/upload" ,
                processData : false,
                contentType : false,
                // async: false,
                data: data,
                success: function (result) {
                    if (result.code == 1) {
                        var input = '#'+ photoRealName;
                        $(input).val(result.data);
                    }else{}
                },
                error : function() {
                    // console.log('异常');
                }
            });
        } else {
            console.log(file.value);
        }
    }

    function login() {
        var url = '1';
        $.ajax({
            type: "POST",//方法类型
            dataType: 'json',//预期服务器返回的数据类型
            url: "/mobile/question/index" ,//url
            data: $('#form1').serialize(),
            success: function (result) {
                if (result.code == 0) {
                    $('#errContent').html(result.msg);
                    $('#myModal').modal('toggle');
                }else {
                    window.location.href=url;
                    //$('#errContent').html(result.msg);
                    // $('#myModal').modal('toggle');
                    //location.reload();
                }
            },
            error : function() {
                $('#errContent').html('网络错误，请刷新重试');
                $('#myModal').modal('toggle');
            }
        });
    }
</script>
</body>
</html>
